package com.qj.yantaishan.controller;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qj.yantaishan.common.annotation.Log;
import com.qj.yantaishan.common.enums.BusinessType;
import com.qj.yantaishan.domain.FxOrderExtend;
import com.qj.yantaishan.service.IFxOrderExtendService;
import com.qj.yantaishan.common.core.controller.BaseController;
import com.qj.yantaishan.common.core.domain.AjaxResult;
import com.qj.yantaishan.common.utils.poi.ExcelUtil;
import com.qj.yantaishan.common.core.page.TableDataInfo;

/**
 * 分销订单扩展Controller
 * 
 * @author qihe
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/yantaishan/FxOrderExtend")
public class FxOrderExtendController extends BaseController
{
    private String prefix = "yantaishan/FxOrderExtend";

    @Autowired
    private IFxOrderExtendService fxOrderExtendService;

    @RequiresPermissions("yantaishan:extend:view")
    @GetMapping()
    public String extend()
    {
        return prefix + "/extend";
    }

    /**
     * 查询分销订单扩展列表
     */
    @RequiresPermissions("yantaishan:extend:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FxOrderExtend fxOrderExtend)
    {
        startPage();
        List<FxOrderExtend> list = fxOrderExtendService.selectFxOrderExtendList(fxOrderExtend);
        return getDataTable(list);
    }

    /**
     * 导出分销订单扩展列表
     */
    @RequiresPermissions("yantaishan:extend:export")
    @Log(title = "分销订单扩展", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FxOrderExtend fxOrderExtend)
    {
        List<FxOrderExtend> list = fxOrderExtendService.selectFxOrderExtendList(fxOrderExtend);
        ExcelUtil<FxOrderExtend> util = new ExcelUtil<FxOrderExtend>(FxOrderExtend.class);
        return util.exportExcel(list, "分销订单扩展数据");
    }

    /**
     * 新增分销订单扩展
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存分销订单扩展
     */
    @RequiresPermissions("yantaishan:extend:add")
    @Log(title = "分销订单扩展", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FxOrderExtend fxOrderExtend)
    {
        return toAjax(fxOrderExtendService.insertFxOrderExtend(fxOrderExtend));
    }

    /**
     * 修改分销订单扩展
     */
    @RequiresPermissions("yantaishan:extend:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        FxOrderExtend fxOrderExtend = fxOrderExtendService.selectFxOrderExtendById(id);
        mmap.put("fxOrderExtend", fxOrderExtend);
        return prefix + "/edit";
    }

    /**
     * 修改保存分销订单扩展
     */
    @RequiresPermissions("yantaishan:extend:edit")
    @Log(title = "分销订单扩展", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FxOrderExtend fxOrderExtend)
    {
        return toAjax(fxOrderExtendService.updateFxOrderExtend(fxOrderExtend));
    }

    /**
     * 删除分销订单扩展
     */
    @RequiresPermissions("yantaishan:extend:remove")
    @Log(title = "分销订单扩展", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(fxOrderExtendService.deleteFxOrderExtendByIds(ids));
    }
}
